using System.IO;
using NMock2;
using NMock2.Monitoring;


namespace NMockExtensions
{
    public class Execute : IAction
    {
        #region Delegates

        public delegate void DelegateAction(Invocation invocation);

        #endregion

        private readonly DelegateAction action;

        private Execute(DelegateAction action)
        {
            this.action = action;
        }

        public void Invoke(Invocation invocation)
        {
            action(invocation);
        }

        public void DescribeTo(TextWriter writer)
        {
        }

        /// Invocation holds all the parameters that were passed to the delegate
        public static IAction Delegate(DelegateAction d)
        {
            return new Execute(d);
        }
    }
}